#ifndef QTEST_PLOT_SCATTER_H_
#define QTEST_PLOT_SCATTER_H_

/**
* @file QTest_XYPlot.h
*/

#include "widgets/plotting/XYPlot.h"

#include <qwt_plot.h>

#include <QtTest/QtTest>
#include <QtGui/QApplication>
#include <QtCore/QVector>

#include <cmath>
#include <cstdio>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

/**
* @class QTestPlotWidget
*
* @brief
*
* @details
*/

using namespace spectrum;
using namespace std;

class QTest_Plot_Scatter : public QObject
{
    private:
        Q_OBJECT

    private slots:
        void test_scatter()
        {
            // Generate some test data.
            const unsigned num_points = 200;
            const double num_periods = 2.0;

            QVector<double> values(num_points);
            for (unsigned i = 0; i < num_points; ++i)
            {
                const double time = (double)i;
                const double freq = num_periods / num_points;
                values[i] = sin(2.0 * M_PI * freq * time);
            }

            // Create a plot canvas.
            _p.push_back(new QwtPlot);
            QwtPlot * p = _p.back();
            p->setMinimumSize(500, 500);
            p->setVisible(true);

            // Create a scatter plot.
            _s.push_back(new XYPlot);
            _s.back()->setPlotStyle(XYPlot::LINE);
            _s.back()->setTitle("My Curve");
            _s.back()->setData(num_points, values.data());
            _s.back()->attach(p);

            // Set the plot title.
            QString title = _s.back()->title().text();
            p->setTitle(title);
        }

    private:
        QVector<QwtPlot*> _p;
        QVector<XYPlot*> _s;
};


int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    QTest_Plot_Scatter test;
    QTest::qExec(&test, argc, argv);
    return app.exec();
}


#endif // QTEST_PLOT_SCATTER_H_
